<template lang="jade">
#account-basic
  .personal-data
    form(v-if='user !== null')
      .form-item.weui-flex
        label 用户名
        .weui-flex__item.readonly(v-html='user.name')
      .form-item.weui-flex
        label 读者证号
        .weui-flex__item.readonly(v-html='user.rdid', disabled)
      .form-item.weui-flex
        label 身份证号
        .weui-flex__item.readonly(v-html='user.cardId', disabled)
      //- .form-item.weui-flex(v-if='user.hasOwnProperty("PatronType")')
      //-   label 用户类型
      //-   input.weui-flex__item.readonly(v-model='user.PatronType', disabled)
      .form-action.weui-flex
        button.btn-blue.weui-btn.weui-btn_primary(@click.stop.prevent='userLogout') 退出登录
    .loading(v-else)
      center #[small 正在加载...]
</template>

<script>
import { mapActions, mapGetters } from 'vuex'

export default {
  name: 'account-basic',
  data () {
    return {
      phone: '18932348732',
      address: '广州珠海',
      email: ''
    }
  },
  computed: {
    ...mapGetters({
      'user': 'userInfo'
    })
  },
  mounted () {
  },
  methods: {
    ...mapActions([
      'logout'
    ]),
    userLogout () {
      this.logout()
      window.localStorage.removeItem('loginId')
      this.$router.replace({ name: 'home' })
    }
  }
}
</script>
